package health.lm.com.shop.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.shop.R;
import health.lm.com.shop.entity.HLChatEntity;

/**
 * Created by Android Studio .
 * Project：hlian health.lm.com.shop.adapter
 * Date：2019/8/9 18:02
 * Introduce：私聊、私聊记录
 */
public class HLChatHistoryAdapter extends BaseQuickAdapter<HLChatEntity, BaseViewHolder> {
    public HLChatHistoryAdapter(@Nullable List<HLChatEntity> data) {
        super(R.layout.hl_activity_chat_item, data);
    }

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper A fully initialized helper.
     * @param item   The item that needs to be displayed.
     */
    @Override
    protected void convert(BaseViewHolder helper, HLChatEntity item) {
        switch (item.getType()) {
            case "2"://别人的信息
                helper.setGone(R.id.constraintLayout_left, true)
                        .setGone(R.id.constraintLayout_right, false)
                        .setText(R.id.textView10, item.getTime())
                        .setText(R.id.textView11, item.getMsg())
                ;
                ImageLoaderHelper.getInstance().load(mContext, item.getHead_img(), helper.getView(R.id.imageView5));
                break;
            case "1"://自己的信息
                helper.setGone(R.id.constraintLayout_left, false)
                        .setGone(R.id.constraintLayout_right, true)
                        .setText(R.id.textView12, item.getTime())
                        .setText(R.id.textView13, item.getMsg())
                ;
                ImageLoaderHelper.getInstance().load(mContext, item.getHead_img(), helper.getView(R.id.imageView6));
                break;
        }
    }
}
